package com.hqyj.system.service.impl;

import com.hqyj.system.mapper.PermissionMapper;
import com.hqyj.system.mapper.RoleMapper;
import com.hqyj.system.mapper.UserMapper;
import com.hqyj.system.model.Permission;
import com.hqyj.system.model.Role;
import com.hqyj.system.model.User;
import com.hqyj.system.service.PermissionService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @ClassName PermissionServiceImpl
 * @Description
 * @Author zlf
 * @Date 2021/9/14 10:17
 * @Version 1.0
 **/
@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<Permission> queryAllPermission() {
        return permissionMapper.queryAllPermission();
    }

    @Override
    public int addPermissionByPermission(Permission permission) {
        return permissionMapper.insertSelective(permission);
    }

    @Override
    public int deletePermissionByPermissionId(int permissionId) {
        return permissionMapper.deleteByPrimaryKey(permissionId);
    }

    @Override
    public Permission queryPermissionByPermissionId(int permissionId) {
        return permissionMapper.selectByPrimaryKey(permissionId);
    }

    @Override
    public Permission query_FJ_PermissionByPermissionId(int permissionId) {
        return permissionMapper.selectByPrimaryKey(permissionId);
    }

    @Override
    public int updatePermissionByPermission(Permission permission) {
        return permissionMapper.updateByPrimaryKeySelective(permission);
    }

    @Override
    public List<Permission> query_xz_permissionByRoleId(int roleId) {
        return permissionMapper.query_xz_permissionByRoleId(roleId);
    }

    @Override
    public List<Permission> queryPermissionByUserId(int userId) {
        return permissionMapper.queryPermissionByUserId(userId);
    }
}
